<template>
    <van-nav-bar title="我的团队列表" left-arrow @click-left="onClickLeft" :fixed="true" />
    <div class="vannavbar"></div>
    <div class="myteamlist">
        <div class="myteamlist_list" v-if="MemberLevelList.length>0">
            <div class="int" :key="index" v-for="Item, index) in MemberLevelList">
                <div class="li">
                    <div class="label"> 账号： </div>
                    <div class="text"> {{Item.Phone}} </div>
                    <div class="state">
                        {{Item.State == 1?'正常':Item.State == 2?'已激活':Item.State == 256?'已出局':Item.State == 512?'禁用':''}}
                    </div>
                    <!-- State (integer, optional): 状态1正常2已激活256已出局512禁用 , -->
                </div>
                <div class="li">
                    <div class="label"> 姓名： </div>
                    <div class="text"> {{Item.NickName}} </div>
                </div>
                <div class="li">
                    <div class="label"> 电话： </div>
                    <div class="text"> {{Item.Phone}} </div>
                </div>
            </div>
        </div>
        <div class="vanEmpty" v-else>
            <van-empty image-size="100px" description="暂无数据" />
        </div>
    </div>
</template>

<script>
    import { onMounted, reactive, ref, toRefs } from 'vue'
    import { Toast, Notify } from 'vant';
    import { useStore } from "vuex"; // ⚪️ 引入状态管理
    import { useRoute, useRouter } from "vue-router";
    import router from "@/router";
    import { GetMemberLevelList, GetMemberLevelCount } from "@/network/myteam";
    export default {
        setup() {
            const store = useStore(); // 获取对象
            const route = useRoute();
            const { Grade } = route.query;
            const state = reactive({
                token: store.state.user.token,
                value: 3,
                Grade: Grade,
                MemberLevelList: []
            });
            onMounted(() => {
                init();
            });
            // 初始化信息
            const init = () => {
                const toast = Toast.loading({
                    duration: 0,
                    forbidClick: true,
                    message: '数据加载中...',
                });
                // 团队级别列表查询
                var params = {
                    memberId: state.token.ID,
                    level: state.Grade
                }
                GetMemberLevelList(params).then((res) => {
                    if (res.Code == 0) {
                        toast.clear()
                        var data = res.Data;
                        state.MemberLevelList = data
                    } else {
                        toast.clear()
                    }
                });
            };
            const onClickLeft  = () => {
                router.push({ path: "/myteam" });
            };
            return {
                ...toRefs(state),
                onClickLeft,
            };
        },
    };
</script>

<style scoped>

</style>